﻿<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>
<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">公司列表</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">公司管理</a>
                </li>
                <li class="breadcrumb-item active">公司列表</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <h4 class="example-title">公司信息</h4>
                    <div class="row">
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">公司名称</label>
                            <input type="text" class="form-control" id="ipt_GongSiMingCheng" name="" placeholder="请输入公司名称" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">成立时间</label>
                            <input type="text" class="form-control empty" autocomplete="off" data-date-format="yyyy-mm-dd" name="" id="ipt_ChengLiShiJian" data-plugin="datepicker" data-language="zh-CN" placeholder="请输入成立时间" />
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">公司地址</label>
                            <input type="text" class="form-control" id="ipt_GongSiDiZhi" name="" placeholder="请输入公司地址" autocomplete="off" />
                        </div>
                        @*<div class="form-group col-sm-4">
                                <label class="control-label" for="inputBasicPassword">负责人</label>
                                <select class="form-control" id="slt_FuZeRen" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                            </div>
                            <div class="form-group col-sm-4">
                                <label class="control-label" for="inputBasicPassword">法人</label>
                                <select class="form-control" id="slt_FaRen" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                            </div>*@
                        @*<div class="form-group col-sm-4 row" style="text-align: center;padding-top:28px">*@
                        <div class="col-sm-6">
                            <button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 100%; float: left;" onclick="bang('查')"><i class="icon wb-search"></i>查询公司</button>
                        </div>
                        <div class="col-sm-6">
                            <button type="button" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 100%;" onclick="ChongZhi();">重置</button>
                        </div>
                        @*</div>*@
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable">
                        <thead>
                            <tr>
                                <th>公司名称</th>
                                <th>成立时间</th>
                                @*<th>公司地址</th>*@
                                <th>联系方式</th>
                                @*<th>负责人</th>*@
                                <th>法人</th>
                                <th>公司规模</th>
                                <th>官方网站</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <th>公司名称</th>
                                <th>成立时间</th>
                                @*<th>公司地址</th>*@
                                <th>联系方式</th>
                                @*<th>负责人</th>*@
                                <th>法人</th>
                                <th>公司规模</th>
                                <th>官方网站</th>
                                <th>操作</th>
                            </tr>
                        </tfoot>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade example-modal-lg" id="exampleFormModal" aria-hidden="true" aria-labelledby="exampleFormModalLabel" role="dialog" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="width: 100%; height: 80%">
        <div class="modal-content" style="width: 100%; height: 80%">
            <div class="modal-header" style="background-color:#0099FF">
                <label id="CunId" style="display:none"></label>
                <button type="button" class="close" data-dismiss="modal" id="guanbiaddkehu" onclick="" aria-label="关闭">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="exampleFormModalLabel">查看公司简介</h4>
            </div>
            <div class="row">
                <div class="form-group col-sm-12"></div>

                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10"></div>
                <div class="form-group col-sm-1"></div>

                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">公司地址</label>
                    <input type="text" class="form-control" id="ipt_GongSiDiZhi2" name="" readonly="readonly" autocomplete="off" />
                </div>
                <div class="form-group col-sm-1"></div>

                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">公司简介</label>
                    <textarea rows="10" class="form-control" style="width:100%" id="ipt_GongSiJianJie" readonly="readonly"></textarea>
                </div>
                <div class="form-group col-sm-1"></div>

                <div class="form-group col-sm-3"></div>
                <div class="form-group col-sm-6">
                    <button type="button" data-dismiss="modal" id="bt_ChongZhiE" class="btn btn-outline btn-success" style="width: 100%;" onclick="">取消</button>
                </div>
                <div class="form-group col-sm-3"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#SpanGongSi").click();
        //获取Id
        var Id = GetQueryString("Id");
        //人员下拉框(没用)
        RenYuanBD();
        //列表显示
        bang("不查", Id);
    })
    //获取Id
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    //绑定公司列表
    function bang(panduan, Id) {
        //是否为添加修改成功后返回的页面
        if (Id == null || Id == undefined) {
            Id = 0;
        } else {
            Id;
        }
        //是不是点击的查询按钮
        if (panduan == "查") {
            ipt_GongSiMingCheng = $("#ipt_GongSiMingCheng").val();
            ipt_ChengLiShiJian = $("#ipt_ChengLiShiJian").val();
            ipt_GongSiDiZhi = $("#ipt_GongSiDiZhi").val();
            //slt_FuZeRen = $("#slt_FuZeRen").find("option:selected").val();
            //slt_FaRen = $("#slt_FaRen").find("option:selected").val();
        } else if (panduan == "不查") {
            ipt_GongSiMingCheng = "";
            ipt_ChengLiShiJian = "";
            ipt_GongSiDiZhi = "";
            //slt_FuZeRen = 0;
            //slt_FaRen = 0;
        }
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample").dataTable().fnDestroy();
        $('#dataTableExample').dataTable({
            "order": [[0, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                console.log(data);
                var param = {};
                param.sw = "";
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;

                param.ipt_GongSiMingCheng = ipt_GongSiMingCheng;
                param.ipt_ChengLiShiJian = ipt_ChengLiShiJian;
                param.ipt_GongSiDiZhi = ipt_GongSiDiZhi;
                //param.slt_FuZeRen = slt_FuZeRen;
                //param.slt_FaRen = slt_FaRen;
                param.Id = Id;
                console.log(param);

                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../GongSi/GetListWithFenYe",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "GongSiMingCheng" },
                { "data": "ChengLiShiJian" },
                //{ "data": "GongSiDiZhi" },
                { "data": "LianXiFangShi" },
                //{ "data": "t_RenYuanBiao_FuZeRen.XingMing" },
                { "data": "FaRen" },
                { "data": "GongSiGuiMo" },
                { "data": "GuanFangWangZhan" },
                { "data": null }
            ]
            ,
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    return '<button type="button" class="btn btn-outline btn-default" onclick="TiaoYeXG(' + row.Id + ')"><i class="icon wb-pencil" aria-hidden="true"></i>修改</button>' +
                        '<a title = "" data-target="#exampleFormModal" class="btn btn-outline btn-default" data-toggle="modal" id="btn_Xz" onclick = "JianJieCK(' + row.Id + ')"><i class="icon wb-search" aria-hidden="true"></i>简介</a>';
                }
            }]
        })
    }
    //人员下拉框(没用)
    function RenYuanBD() {
        //$.ajax({
        //    type: 'POST',
        //    url: '../GongSi/GetSelRenYuan',
        //    dataType: 'json',
        //    data: {},
        //    success: function (date) {
        //        console.log(date)
        //        var XLK = $("#slt_FuZeRen");
        //        var XLK2 = $("#slt_FaRen");
        //        XLK.append("<option value='0'>请选择</option>");
        //        XLK2.append("<option value='0'>请选择</option>");
        //        $(date).each(function (key) {
        //            var opt = $("<option></option>").text(date[key].XingMing).val(date[key].Id);
        //            var opt2 = $("<option></option>").text(date[key].XingMing).val(date[key].Id);
        //            XLK.append(opt);
        //            XLK2.append(opt2);
        //        })
        //    },
        //});
    }
    //文本重置
    function ChongZhi() {
        $("#ipt_GongSiMingCheng").val('');
        $("#ipt_ChengLiShiJian").val('');
        $("#ipt_GongSiDiZhi").val('');
        $("#slt_FuZeRen").val(0);
        $("#slt_FaRen").val(0);
        bang("不查");
    }
    //跳页面修改
    function TiaoYeXG(Id) {
        location.href = "../GongSi/GongSiAdd?Id=" + Id;
    }
    //绑定弹层信息
    function JianJieCK(Id) {
        $.ajax({
            url: '../GongSi/GetById',
            data: { Id: Id },
            type: "post",
            dataType: "json",
            success: function (response) {
                console.log(response);
                $(response).each(function (key) {
                    console.log(response[key].Id);
                    $("#ipt_GongSiJianJie").val(response[key].GongSiJianJie);
                    $("#ipt_GongSiDiZhi2").val(response[key].GongSiDiZhi);
                })
            }
        });
    }
</script>